package Leetcode.StackAndQueue.largestRectangleArea84;

/**
 * 暴力解法超出时间限制
 * 时间复杂度O(n^3)
 */
public class Solution {
    public int largestRectangleArea(int[] heights) {
        int Area = 0;

        if(heights.length == 1) {
            return heights[0];
        }
        if(heights.length == 0) {
            return 0;
        }
        for(int i = 0; i < heights.length ; i ++) {
            int height = 0;
            for(int j = i  ; j < heights.length; j++) {
                for(int k = i; k <= j; k++ ) {
                    if(k == i) {
                        height = heights[k];

                    }
                    height = Math.min(height,heights[k]);
                }
                Area = Math.max(height * (j - i + 1),Area);
            }
        }

        return Area;
    }

    public static void main(String[] args) {
        int nums[] = {0,9};
        Solution solution = new Solution();
        System.out.println(solution.largestRectangleArea(nums));
    }
}
